package com.mall507.fivepeaks.widget.xdialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.mall507.fivepeaks.R;

/**
 * 用户邀请码定制code
 * */
public class XUserYqCode1Dialog{

	private Dialog alertDialog;
	
	
	/**
	 * @param context
	 * @param code 提示消息
	 * @param callback 选择结果回调
	 * */
	public void show(final Context context,final String msg,final XUserYqCodeDialog1CallBack callback) {
		//防止网络延迟情况下多次点击弹出多个窗口
		dismiss();
		alertDialog = new Dialog(context, R.style.XDialog_RemoveAllStyle);
		LayoutInflater in = LayoutInflater.from(context);
		View viewDialog = in.inflate(R.layout.view_xdialog_user_yq_code1, null);
		((TextView) viewDialog.findViewById(R.id.msg)).setText(msg);
		TextView button=(TextView) viewDialog.findViewById(R.id.button);
		button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				callback.confirm();
			}
		});
		alertDialog.setContentView(viewDialog);
		// 点击对话框外部取消对话框显示
		alertDialog.setCanceledOnTouchOutside(false);
		alertDialog.show();
	}
	
	/**
	 * 关闭当前Dialog
	 * */
	public void dismiss(){
		if(alertDialog!=null && alertDialog.isShowing()){
			alertDialog.dismiss();
		}
	}
	
	/**
	 * 自编邀请码
	 * */
	public interface XUserYqCodeDialog1CallBack{
		  void confirm();
		  
	}
}
